home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Tool Chest / Interfaces & Libraries / Interfaces / AIncludes / MIDI.a < prev    next >
Encoding:
Text File  |  1993-12-02  |  11.2 KB  |  477 lines  |  [TEXT/MPS ]

  1. ;    File:        MIDI.a
  2. ;
  3. ;    Copyright:    © 1983-1993 by Apple Computer, Inc.
  4. ;                All rights reserved.
  5. ;
  6. ;    Version:    System 7.1 for ETO #11
  7. ;    Created:    Tuesday, March 30, 1993 18:00
  8. ;
  9. ;___________________________________________________________________________
  10.  
  11.     IF &TYPE('__INCLUDINGMIDI__') = 'UNDEFINED' THEN
  12. __INCLUDINGMIDI__    SET    1
  13.  
  14.     IF &TYPE('__INCLUDINGTRAPS__') = 'UNDEFINED' THEN
  15.     INCLUDE 'Traps.a'
  16.     ENDIF
  17.  
  18.  
  19. ;;; _______________________________________________________________________________
  20. ;;;
  21. ;;;  Constants:
  22. ;;;
  23.  
  24. midiToolNum       EQU         4                         ; tool number of MIDI Mgr for SndDispVersion call.
  25. midiMaxNameLen    EQU         31                        ; maximum number of characters in port and client names
  26.  
  27.  
  28. ; Time formats
  29.  
  30. midiFormatMSec    EQU         0                         ; milliseconds
  31. midiFormatBeats   EQU         1                         ; beats
  32. midiFormat24fpsBit EQU        2                         ; 24 frames/sec.
  33. midiFormat25fpsBit EQU        3                         ; 25 frames/sec.
  34. midiFormat30fpsDBit EQU       4                         ; 30 frames/sec. drop-frame
  35. midiFormat30fpsBit EQU        5                         ; 30 frames/sec.
  36. midiFormat24fpsQF EQU         6                         ; 24 frames/sec. longInt format
  37. midiFormat25fpsQF EQU         7                         ; 25 frames/sec. longInt format
  38. midiFormat30fpsDQF EQU        8                         ; 30 frames/sec. drop-frame longInt format
  39. midiFormat30fpsQF EQU         9                         ; 30 frames/sec. longInt format
  40. midiInternalSync  EQU         0                         ; internally synced
  41. midiExternalSync  EQU         1                         ; externally synced
  42.  
  43.  
  44. ; Port types
  45.  
  46. midiPortTypeTime  EQU         0                         ; time port
  47. midiPortTypeInput EQU         1                         ; input port
  48. midiPortTypeOutput EQU        2                         ; output port
  49. midiPortTypeTimeInv EQU       3                         ; invisible time port
  50.  
  51.  
  52. ; OffsetTimes
  53.  
  54. midiGetEverything EQU         $7FFFFFFF                 ; get all packets, regardless of time stamps
  55. midiGetNothing    EQU         $80000000                 ; get no packets, regardless of time stamps
  56. midiGetCurrent    EQU         $00000000                 ; get current packets only
  57.  
  58.  
  59.  
  60. ;;;
  61. ;;; MIDI data and messages are passed in MIDIPacket records (see below).
  62. ;;; The first byte of every MIDIPacket contains a set of flags
  63. ;;;
  64. ;;; bits 0-1   00 = new MIDIPacket, not continued
  65. ;;;                01 = begining of continued MIDIPacket
  66. ;;;                10 = end of continued MIDIPacket
  67. ;;;                11 = continuation
  68. ;;; bits 2-3            reserved
  69. ;;;
  70. ;;;bits 4-6  000 = MIDIPacket contains MIDI data
  71. ;;;               001 = MIDIPacket contains MIDI Manager message
  72. ;;;
  73. ;;;  bit 7            0 = MIDIPacket has valid stamp
  74. ;;;                   1 = stamp with current clock
  75. ;;;
  76.  
  77. midiContMask      EQU         $03
  78. midiNoCont        EQU         $00
  79. midiStartCont     EQU         $01
  80. midiMidCont       EQU         $03
  81. midiEndCont       EQU         $02
  82. midiTypeMask      EQU         $70
  83. midiMsgType       EQU         $00
  84. midiMgrType       EQU         $10
  85. midiTimeStampMask EQU         $80
  86. midiTimeStampCurrent EQU      $80
  87. midiTimeStampValid EQU        $00
  88.  
  89.  
  90. ;  MIDI Manager MIDIPacket command words (the first word in the data field
  91. ;  for midiMgrType messages)
  92.  
  93. midiOverflowErr   EQU         $0001
  94. midiSCCErr        EQU         $0002
  95. midiPacketErr     EQU         $0003
  96. midiMaxErr        EQU         $00FF                     ; all command words less than this value
  97. ;    are error indicators
  98.  
  99. ;;; _______________________________________________________________________________
  100. ;;;
  101. ;;;  valid results to be returned from readHooks
  102. ;;;
  103.  
  104. midiKeepPacket    EQU         0
  105. midiMorePacket    EQU         1
  106. midiNoMorePacket  EQU         2
  107.  
  108.  
  109. ;;; _______________________________________________________________________________
  110. ;;;
  111. ;;;  Errors:
  112. ;;;
  113.  
  114. midiNoClientErr   EQU         -250                      ; no client with that ID found
  115. midiNoPortErr     EQU         -251                      ; no port with that ID found
  116. midiTooManyPortsErr EQU       -252                      ; too many ports already installed in the system
  117. midiTooManyConsErr EQU        -253                      ; too many connections made
  118. midiVConnectErr   EQU         -254                      ; pending virtual connection created
  119. midiVConnectMade  EQU         -255                      ; pending virtual connection resolved
  120. midiVConnectRmvd  EQU         -256                      ; pending virtual connection removed
  121. midiNoConErr      EQU         -257                      ; no connection exists between specified ports
  122. midiWriteErr      EQU         -258                      ; MIDIWritePacket couldn't write to all connected ports
  123. midiNameLenErr    EQU         -259                      ; name supplied is longer than 31 characters
  124. midiDupIDErr      EQU         -260                      ; duplicate client ID
  125. midiInvalidCmdErr EQU         -261                      ; command not supported for port type
  126.  
  127.  
  128. ;;; _______________________________________________________________________________
  129. ;;;
  130. ;;;  Driver calls:
  131. ;;;
  132.  
  133. midiOpenDriver    EQU         1
  134. midiCloseDriver   EQU         2
  135.  
  136.  
  137.  
  138. ;;; ________________________________________________________________________________
  139. ;;;
  140. ;;;  MIDI data and other messages are read and written in packets:
  141. ;;;
  142.  
  143. MIDIPacket        RECORD      0
  144. flags             DS.B        1
  145. len               DS.B        1
  146. tStamp            DS.L        1
  147. data              EQU         *
  148.                   ENDR
  149.  
  150.  
  151. ;;; _______________________________________________________________________________
  152. ;;;
  153. ;;;  port information
  154. ;;;
  155.  
  156. MIDIIDRec         RECORD      0
  157. clientID          DS.L        1
  158. portID            DS.L        1
  159.                   ENDR
  160.  
  161. MIDIPortParams    RECORD      0
  162. portID            DS.L        1                         ; ID of port, unique within client
  163. portType          DS.W        1                         ; Type of port - input, output, time, etc.
  164. timeBase          DS.W        1                         ; refnum of time base, 0 if none
  165. offsetTime        DS.L        1                         ; offset for current time stamps
  166. readHook          DS.L        1                         ; routine to call when input data is valid
  167. refCon            DS.L        1                         ; refcon for port (for client use)
  168. sync              DS.W        1                         ; internal, external,other
  169. curTime           DS.L        1                         ; current local time for the port
  170. format            DS.W        1                         ; time code format in use
  171. name              DS.B        256                       ; name of the port. This is a real live string, not a ptr.
  172.  
  173. size              EQU         *                         ; size of port params
  174.                   ENDR
  175.  
  176. MIDIPortInfo      RECORD      0
  177. portType          DS.W        1                         ; type of port
  178. timeBase          DS.L        2                         ; MIDIIDRec for time base
  179. numConnects       DS.W        1                         ; number of connections
  180. cList             EQU         *                         ; ARRAY [1..numConnects] of MIDIIDRec
  181.                   ENDR
  182.  
  183.  
  184. ;;; _______________________________________________________________________________
  185. ;;;
  186. ;;; Clocks:
  187. ;;;
  188.  
  189. MIDIClkInfo       RECORD      0
  190. sync              DS.W        1                         ; 0 = internal,  1 = external
  191. curTime           DS.L        1                         ; current value of port's clock
  192. format            DS.W        1                         ; time code format
  193. size              EQU         *                         ; size of MIDIClkInfo
  194.                   ENDR
  195.  
  196.  
  197. ;;; _______________________________________________________________________________
  198. ;;;
  199. ;;;  Equates for function selectors
  200. ;;;
  201.  
  202. midiVersion       EQU         0
  203. midiSignIn        EQU         4
  204. midiSignOut       EQU         8
  205. midiGetClients    EQU         12
  206. midiGetClientName EQU         16
  207. midiSetClientName EQU         20
  208. midiGetPorts      EQU         24
  209. midiAddPort       EQU         28
  210. midiGetPortInfo   EQU         32
  211. midiConnectData   EQU         36
  212. midiUnConnectData EQU         40
  213. midiConnectTime   EQU         44
  214. midiUnConnectTime EQU         48
  215. midiFlush         EQU         52
  216. midiGetReadHook   EQU         56
  217. midiSetReadHook   EQU         60
  218. midiGetPortName   EQU         64
  219. midiSetPortName   EQU         68
  220. midiWakeUp        EQU         72
  221. midiRemovePort    EQU         76
  222. midiGetSync       EQU         80
  223. midiSetSync       EQU         84
  224. midiGetCurTime    EQU         88
  225. midiSetCurTime    EQU         92
  226. midiStartTime     EQU         96
  227. midiStopTime      EQU         100
  228. midiPoll          EQU         104
  229. midiWritePacket   EQU         108
  230. midiWorldChanged  EQU         112
  231. midiGetOffsetTime EQU         116
  232. midiSetOffsetTime EQU         120
  233. midiConvertTime   EQU         124
  234. midiGetRefCon     EQU         128
  235. midiSetRefCon     EQU         132
  236. midiGetClRefCon   EQU         136
  237. midiSetClRefCon   EQU         140
  238. midiGetTCFormat   EQU         144
  239. midiSetTCFormat   EQU         148
  240. midiSetRunRate    EQU         152
  241. midiGetClientIcon EQU         156
  242.  
  243.  
  244. ;;; ________________________________________________________________________________
  245. ;;;
  246. ;;; Call Macros for Assembly
  247. ;;;
  248.  
  249.                                                         ;;
  250.                                                         ;;    fake _SndDispVersion which calls glue to make sure that the sound
  251.                                                         ;;    dispatcher has been installed
  252.                                                         ;;
  253.                   IMPORT      SndDispVersion
  254.  
  255.                   MACRO
  256. &label            _SndDispVersion
  257. &label            JSR         SndDispVersion    
  258.                                                         ; call the sound dispatcher glue in MIDIGlue.o
  259.                   ENDM
  260.  
  261.  
  262.                   MACRO
  263. &label            _CallMIDIMgr &selector
  264. &label            MOVE.L      #(&selector<<16)+midiToolNum,D0
  265.                   _SoundDispatch
  266.                   ENDM
  267.  
  268.  
  269.                   MACRO
  270. &label            _MIDISignIn
  271. &label            _CallMIDIMgr midiSignIn
  272.                   MEND
  273.  
  274.                   MACRO
  275. &label            _MIDISignOut
  276. &label            _CallMIDIMgr midiSignOut
  277.                   MEND
  278.  
  279.                   MACRO
  280. &label            _MIDIVersion
  281. &label            _CallMIDIMgr midiVersion
  282.                   MEND
  283.  
  284.                   MACRO
  285. &label            _MIDIGetClients
  286. &label            _CallMIDIMgr midiGetClients
  287.                   MEND
  288.  
  289.                   MACRO
  290. &label            _MIDIGetClientName
  291. &label            _CallMIDIMgr midiGetClientName
  292.                   MEND
  293.  
  294.                   MACRO
  295. &label            _MIDISetClientName
  296. &label            _CallMIDIMgr midiSetClientName
  297.                   MEND
  298.  
  299.                   MACRO
  300. &label            _MIDIGetPorts
  301. &label            _CallMIDIMgr midiGetPorts
  302.                   MEND
  303.                 
  304.                   MACRO
  305. &label            _MIDIAddPort
  306. &label            _CallMIDIMgr midiAddPort
  307.                   MEND
  308.  
  309.  
  310.                   MACRO
  311. &label            _MIDIGetPortInfo
  312. &label            _CallMIDIMgr midiGetPortInfo
  313.                   MEND
  314.  
  315.                   MACRO
  316. &label            _MIDIConnectData
  317. &label            _CallMIDIMgr midiConnectData
  318.                   MEND
  319.  
  320.  
  321.                   MACRO
  322. &label            _MIDIUnConnectData
  323. &label            _CallMIDIMgr midiUnConnectData
  324.                   MEND
  325.  
  326.                   MACRO
  327. &label            _MIDIConnectTime
  328. &label            _CallMIDIMgr midiConnectTime
  329.                   MEND
  330.  
  331.                   MACRO
  332. &label            _MIDIUnConnectTime
  333. &label            _CallMIDIMgr midiUnConnectTime
  334.                   MEND
  335.  
  336.                   MACRO
  337. &label            _MIDIFlush
  338. &label            _CallMIDIMgr midiFlush
  339.                   MEND
  340.  
  341.                   MACRO
  342. &label            _MIDIGetReadHook
  343. &label            _CallMIDIMgr midiGetReadHook
  344.                   MEND
  345.  
  346.                   MACRO
  347. &label            _MIDISetReadHook
  348. &label            _CallMIDIMgr midiSetReadHook
  349.                   MEND
  350.  
  351.                   MACRO
  352. &label            _MIDIGetPortName
  353. &label            _CallMIDIMgr midiGetPortName
  354.                   MEND
  355.  
  356.                   MACRO
  357. &label            _MIDISetPortName
  358. &label            _CallMIDIMgr midiSetPortName
  359.                   MEND
  360.  
  361.                   MACRO
  362. &label            _MIDIWakeUp
  363. &label            _CallMIDIMgr midiWakeUp
  364.                   MEND
  365.  
  366.                   MACRO
  367. &label            _MIDIRemovePort
  368. &label            _CallMIDIMgr midiRemovePort
  369.                   MEND
  370.  
  371.                   MACRO
  372. &label            _MIDIGetSync
  373. &label            _CallMIDIMgr midiGetSync
  374.                   MEND
  375.  
  376.  
  377.  
  378.  
  379.  
  380.                   MACRO
  381. &label            _MIDISetSync
  382. &label            _CallMIDIMgr midiSetSync
  383.                   MEND
  384.  
  385.                   MACRO
  386. &label            _MIDIGetCurTime
  387. &label            _CallMIDIMgr midiGetCurTime
  388.                   MEND
  389.  
  390.                   MACRO
  391. &label            _MIDISetCurTime
  392. &label            _CallMIDIMgr midiSetCurTime
  393.                   MEND
  394.  
  395.                   MACRO
  396. &label            _MIDIStartTime
  397. &label            _CallMIDIMgr midiStartTime
  398.                   MEND
  399.  
  400.                   MACRO
  401. &label            _MIDIStopTime
  402. &label            _CallMIDIMgr midiStopTime
  403.                   MEND
  404.  
  405.                   MACRO
  406. &label            _MIDIPoll
  407. &label            _CallMIDIMgr midiPoll
  408.                   MEND
  409.  
  410.                   MACRO
  411. &label            _MIDIWritePacket
  412. &label            _CallMIDIMgr midiWritePacket
  413.                   MEND
  414.  
  415.                   MACRO
  416. &label            _MIDIWorldChanged
  417. &label            _CallMIDIMgr midiWorldChanged
  418.                   MEND
  419.  
  420.                   MACRO
  421. &label            _MIDIGetOffsetTime
  422. &label            _CallMIDIMgr midiGetOffsetTime
  423.                   MEND
  424.  
  425.                   MACRO
  426. &label            _MIDISetOffsetTime
  427. &label            _CallMIDIMgr midiSetOffsetTime
  428.                   MEND
  429.  
  430.                   MACRO
  431. &label            _MIDIConvertTime
  432. &label            _CallMIDIMgr midiConvertTime
  433.                   MEND
  434.  
  435.                   MACRO
  436. &label            _MIDIGetRefCon
  437. &label            _CallMIDIMgr midiGetRefCon
  438.                   MEND
  439.  
  440.                   MACRO
  441. &label            _MIDISetRefCon
  442. &label            _CallMIDIMgr midiSetRefCon
  443.                   MEND
  444.  
  445.                   MACRO
  446. &label            _MIDIGetClRefCon
  447. &label            _CallMIDIMgr midiGetClRefCon
  448.                   MEND
  449.  
  450.                   MACRO
  451. &label            _MIDISetClRefCon
  452. &label            _CallMIDIMgr midiSetClRefCon
  453.                   MEND
  454.  
  455.                   MACRO
  456. &label            _MIDIGetTCFormat
  457. &label            _CallMIDIMgr midiGetTCFormat
  458.                   MEND
  459.  
  460.                   MACRO
  461. &label            _MIDISetTCFormat
  462. &label            _CallMIDIMgr midiSetTCFormat
  463.                   MEND
  464.  
  465.                   MACRO
  466. &label            _MIDISetRunRate
  467. &label            _CallMIDIMgr midiSetRunRate
  468.                   MEND
  469.  
  470.                   MACRO
  471. &label            _MIDIGetClientIcon
  472. &label            _CallMIDIMgr midiGetClientIcon
  473.                   MEND
  474.  
  475.  
  476.  
  477.     ENDIF    ; ...already included